package yxy.game.pm2.command.kow;

import yxy.cherry.game.base.message.MessageEmitterHandler;
import yxy.cherry.game.base.message.annotation.MessageSource;
import yxy.cherry.game.base.message.annotation.MessageType;
import yxy.game.pm2.Result;
import yxy.game.pm2.command.Command;
import yxy.game.pm2.message.KowMessage;
import yxy.game.pm2.module.kow.KowHandle;

/** 天下第一 天下第一淘汰赛详情 */
@MessageType(proto = Command.KowFinalInfo, classtype = KowMessage.KowFinalInfoRequest.class)
public class CMD_KowFinalInfo extends Command<KowMessage.KowFinalInfoRequest> {

	@Override
	public void execute(MessageSource messageSource, KowMessage.KowFinalInfoRequest request) {
		String playerCode = messageSource.getTag();

		KowMessage.KowFinalInfoResponse.Builder response = KowMessage.KowFinalInfoResponse.newBuilder();

		Result result = new KowHandle().finalFanInfo(playerCode, response);

		send(messageSource, response, result);
	}

	private void send(MessageSource messageSource, KowMessage.KowFinalInfoResponse.Builder response, Result result) {
		response.setResult(result.packResult());
		MessageEmitterHandler.getInstance().send(messageSource, response.build());
	}
}